/**
 * 版本选择组件
 */

import React from 'react';
import Group from './Group.jsx';

import SelectField from 'material-ui/lib/select-field';
import MenuItem from 'material-ui/lib/menus/menu-item';


export default class VersionGroup extends React.Component {

	static defaultProps = {
		versions: [],
	};

	static propTypes = {
		onChange: React.PropTypes.func
	};

	constructor(props) {
		super(props);
	}

	render() {
		let { versions, selectedVersion, onChange } = this.props;
		
		return (
			<Group name='版本'>
				<SelectField
					value={selectedVersion}
					onChange={(event, index, value) => onChange(value)}
				>
					<MenuItem primaryText='全部' value={'0'} key={-1}  />
					{
						versions.map((item, index) => 
							<MenuItem 
								primaryText={item.enum} 
								value={item.enum.toString()} 
								key={index} />)
					}
				</SelectField>
			</Group>
		);
	}
}